import { useState } from "react"

function DemoA() {
  let [num, setNum] = useState(0)

  let renderHn = () => {
    let res = null;
    switch (num) {
      case 0:
        res = <h1>我是h1</h1>
        break;
      case 1:
        res = <h2>我是h2</h2>
        break;
      case 2:
        res = <h3>我是h3</h3>
        break;
    }
    return res;
  }

  return (
    <div>
      {renderHn()}
      <button onClick={() => setNum(((num + 1) % 3))}>改变num</button>
    </div>
  )
}

export default DemoA;

